package com.leyou.goods.item.service;

import com.leyou.goods.item.dao.CategoryDao;
import com.leyou.goods.item.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class CategoryService {
    @Autowired(required = false)
    private CategoryDao categoryDao;

    public List<Category> getAllCategory(Long pid) {
        Category category = new Category();
        category.setParentId(pid);
        return  categoryDao.select(category);
    }

        public List<String> queryNamesByIds(List<Long> ids) {
        System.out.println(categoryDao);
        List<Category> list = this.categoryDao.selectByIdList(ids);

            List<String> names = new ArrayList<>();
            for (Category category : list) {
                names.add(category.getName());
            }
            return names;
        }
}
